﻿using System;
using System.Collections;
using System.Collections.Specialized;
using System.Runtime.Serialization;
using System.Web;

namespace NWebMock
{
    public interface IHttpCookieCollection : ICollection, ISerializable
    {
        #region Properties

        /// <summary>
        /// Gets a string array containing all the keys (cookie names) in the cookie collection.
        /// </summary>
        string[] AllKeys { get; }

        /// <summary>
        /// Gets the cookie with the specified numerical index from the cookie collection.
        /// </summary>
        /// <param name="index">The index of the cookie to retrieve from the collection. </param>
        /// <returns>The HttpCookie specified by index.</returns>
        HttpCookie this[int index] { get; }

        /// <summary>
        /// Gets the cookie with the specified name from the cookie collection.
        /// </summary>
        /// <param name="name">Name of cookie to retrieve. </param>
        /// <returns>The HttpCookie specified by name.</returns>
        HttpCookie this[string name] { get; }

        /// <summary>
        /// Gets a NameObjectCollectionBase.KeysCollection instance that contains all the keys in the NameObjectCollectionBase instance.
        /// </summary>
        ICollection Keys { get; }

        #endregion

        #region Methods

        /// <summary>
        /// Adds the specified cookie to the cookie collection.
        /// </summary>
        /// <param name="cookie">The HttpCookie to add to the collection. </param>
        void Add(HttpCookie cookie);

        /// <summary>
        /// Clears all cookies from the cookie collection.
        /// </summary>
        void Clear();

        /// <summary>
        /// Returns the HttpCookie item with the specified index from the cookie collection.
        /// </summary>
        /// <param name="index">The index of the cookie to return from the collection. </param>
        /// <returns>The HttpCookie specified by index.</returns>
        HttpCookie Get(int index);

        /// <summary>
        /// Returns the cookie with the specified name from the cookie collection.
        /// </summary>
        /// <param name="name">The name of the cookie to retrieve from the collection. </param>
        /// <returns>The HttpCookie specified by name.</returns>
        HttpCookie Get(string name);

        /// <summary>
        /// Returns the key (name) of the cookie at the specified numerical index.
        /// </summary>
        /// <param name="index">The index of the key to retrieve from the collection. </param>
        /// <returns>The name of the cookie specified by index.</returns>
        string GetKey(int index);

        /// <summary>
        /// Implements the ISerializable interface and raises the deserialization event when the deserialization is complete.
        /// </summary>
        /// <param name="sender">The source of the deserialization event.</param>
        void OnDeserialization(Object sender);

        /// <summary>
        /// Removes the cookie with the specified name from the collection.
        /// </summary>
        /// <param name="name">The name of the cookie to remove from the collection. </param>
        void Remove(string name);

        /// <summary>
        /// Updates the value of an existing cookie in a cookie collection.
        /// </summary>
        /// <param name="cookie">The HttpCookie object to update. </param>
        void Set(HttpCookie cookie);

        #endregion
    }
}
